﻿using System;
using System.Collections.Generic;
using System.Net;
using SqlSugar;
using XiheNet.Data;

// * * * * * * * * * * * * * * *
// * company: xihekeji.com     *
// * date: 2024-11-23          *
// * author: skirtboy@qq.com   *
// * * * * * * * * * * * * * * *

namespace Com.Entity
{
    [SugarTable("T_Book", TableDescription = "图书")]
    public class TBookEntity:DeltEntity
    {
        public int Type { get; set; }                                   // 类型;2外部、1内部
        public string ISBN { get; set; } = string.Empty;                                  // 国际标准书号
        public string Name { get; set; } = string.Empty;                // 书名
        public string Author { get; set; } = string.Empty;              // 作者
        public string Press { get; set; } = string.Empty;               // 出版社
        public string PublishDate { get; set; } = string.Empty;         // 出版日期
        public string Edition { get; set; } = string.Empty;             // 版次
        public string Cover { get; set; } = string.Empty;               // 封面图片
        public decimal Price { get; set; }                              // 定价
        public string OssFolder { get; set; } = string.Empty;           // OSS文件夹名
        public int CreateUserID { get; set; }                           // 创建人
        public int DeltUserID { get; set; }                             // 删除人
        public int OldAppId { get; set; }                               // 原系统标识



        #region 时间格式化
        [SugarColumn(IsIgnore = true)]
        public string CreateTimeDT { get => CreateTime.ToString("yyyy-MM-dd HH:mm:ss"); }

        [SugarColumn(IsIgnore = true)]
        public string DeltTimeDT { get => DeltTime.ToString("yyyy-MM-dd HH:mm:ss"); }
        #endregion



        #region 联表
        // 创建人
        [Navigate(NavigateType.OneToOne, nameof(CreateUserID))]
        public SAdminEntity CreateUser { get; set; }

        // 删除人
        [Navigate(NavigateType.OneToOne, nameof(DeltUserID))]
        public SAdminEntity DeltUser { get; set; }

        // 电子书
        [Navigate(NavigateType.OneToMany, nameof(TEBookEntity.BookId))]
        public List<TEBookEntity> EBooks { get; set; }

        // 激活记录
        [Navigate(NavigateType.OneToOne, nameof(Id), nameof(TBookActivateEntity.BookId))]
        public TBookActivateEntity Activate { get; set; }

        #endregion

    }
}